//
//  NSUserDefaults+DCFUser.m
//  MZB
//
//  Created by 吴文拼 on 2017/12/12.
//  Copyright © 2017年 吴文拼. All rights reserved.
//

#import "NSUserDefaults+DCFUser.h"

@implementation NSUserDefaults (DCFUser)


- (NSString *)DCF_keyForCurrentUser:(NSString *)key
{
    return [NSString stringWithFormat:@"%@-%@",[self DCF_currentUsid], key];
}

- (NSString *)DCF_currentUsid
{
    NSString *usidInString = @"";
    
//    NSNumber *usid = [DCFLoginManager sharedInstance].currentUser.userId;
//
//    if (usid) {
//
//        if ([usid isKindOfClass:[NSNumber class]]) {
//            usidInString = [[DCFLoginManager sharedInstance].currentUser.userId stringValue];
//        } else {
//            usidInString = (NSString *)usid;
//        }
//    }

    return usidInString;
}





- (NSArray *)DCF_arrayForKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    return [self arrayForKey:keyForCurrentUser];
}

- (BOOL)DCF_boolForKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    return [self boolForKey:keyForCurrentUser];
}

- (NSData *)DCF_dataForKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    return [self dataForKey:keyForCurrentUser];
}

- (NSDictionary *)DCF_dictionaryForKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    return [self dictionaryForKey:keyForCurrentUser];
}

- (float)DCF_floatForKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    return [self floatForKey:keyForCurrentUser];
}

- (NSInteger)DCF_integerForKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    return [self integerForKey:keyForCurrentUser];
}

- (id)DCF_objectForKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    return [self objectForKey:keyForCurrentUser];
}

- (NSArray *)DCF_stringArrayForKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    return [self stringArrayForKey:keyForCurrentUser];
}

- (NSString *)DCF_stringForKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    return [self stringForKey:keyForCurrentUser];
}

- (double)DCF_doubleForKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    return [self doubleForKey:keyForCurrentUser];
}

- (NSURL *)DCF_URLForKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    return [self URLForKey:keyForCurrentUser];
}

- (void)DCF_setBool:(BOOL)value forKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    [self setBool:value forKey:keyForCurrentUser];
}

- (void)DCF_setFloat:(float)value forKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    [self setFloat:value forKey:keyForCurrentUser];
}

- (void)DCF_setInteger:(NSInteger)value forKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    [self setInteger:value forKey:keyForCurrentUser];
}

- (void)DCF_setObject:(id)value forKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    [self setObject:value forKey:keyForCurrentUser];
}

- (void)DCF_setDouble:(double)value forKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    [self setDouble:value forKey:keyForCurrentUser];
}

- (void)DCF_setURL:(NSURL *)url forKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    [self setURL:url forKey:keyForCurrentUser];
}



- (void)DCF_removeObjectForKey:(NSString *)defaultName
{
    NSString *keyForCurrentUser = [self DCF_keyForCurrentUser:defaultName];

    [self removeObjectForKey:keyForCurrentUser];
}



@end

